package richbar.com.richbar.activity.order;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.common.base.BaseActivity;
import com.common.util.LogUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import richbar.com.richbar.R;
import richbar.com.richbar.adapter.order.MainAdapter;
import richbar.com.richbar.fragment.order.BaseOrderFragment;
import richbar.com.richbar.help.TitleHelp;

/**
 * Created by QiYang on 2018/11/29.
 */

public class OrderListAc extends BaseActivity {
    @BindView(R.id.layout_tab)
    TabLayout layoutTab;
    @BindView(R.id.viewpager)
    ViewPager viewpager;
    private MainAdapter adapter;

    @Override
    public int initLayout() {
        return R.layout.ac_order_list;
    }

    @Override
    public void initTitle() {
        new TitleHelp(this).setTitle("我的订单");
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        LogUtil.e("AAADDDDDAAA","进来了11");
    }

    public int getPos(){
        int pos = getBundle().getInt("pos");
        return pos;
    }

    @Override
    public void initData() {
        String[] titles = {"全部","待付款","待发货","待收货","售后"};
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(BaseOrderFragment.newInstance(0));
        fragments.add(BaseOrderFragment.newInstance(1));
        fragments.add(BaseOrderFragment.newInstance(2));
        fragments.add(BaseOrderFragment.newInstance(3));
        fragments.add(BaseOrderFragment.newInstance(4));
        adapter = new MainAdapter(titles,fragments,getSupportFragmentManager());
        viewpager.setAdapter(adapter);
        viewpager.setCurrentItem(getPos());
        viewpager.setOffscreenPageLimit(5);
        layoutTab.setupWithViewPager(viewpager);
        viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

}
